
/* Tabpage Javascript code

	Author: Jonathan Slenders
*/

function init()
{
	var containers = document.getElementsByTagName('div');

	for (var i = 0; i < containers.length; i ++)
		if (containers[i].className == 'tabpage_container')
			init_tabpage(containers[i]);
}

function init_tabpage(container)
{
	var tabs_header = container.getElementsByTagName('ul').item(0);

	var tabs = tabs_header.getElementsByTagName('li');
	var pages = [];

	for (var i = 0; i < container.childNodes.length; i ++)
		if (container.childNodes[i].className == 'tabpage_page')
			pages.push(container.childNodes[i]);

	var show_page = function(i)
	{
		for (var j = 0; j < pages.length; j ++)
		{
			pages[j].style.display = (i == j ? 'block' : 'none');
			tabs[j].className = (i == j ? 'tabpage_active_tab tabpage_tab': 'tabpage_tab');
		}
	}

	function init_tabpage_page(i)
	{
		tabs[i].addEventListener('click', function() { show_page(i) }, false);
	}

	for (var i = 0; i < tabs.length; i ++)
		init_tabpage_page(i);

	show_page(0);
}


document.addEventListener("DOMContentLoaded", init, null);
